# 种向日葵
import common

def plantSunflower(start_x,start_y,end_x,end_y):
	
	flag = False
	while True:
		if flag:
			break
		sunFlower = []
		sunFlowerLen = [0,0,0,0,0,0,0,0,0]
		for i in range(start_x,end_x+1):
			for j in range(start_y,end_y+1):
				common.move_abs(i,j)
				if get_ground_type() != Grounds.Soil:
					till()
				if get_entity_type() != Entities.Sunflower:
					plant(Entities.Sunflower)
				sun = measure() - 7
				sunFlower.insert(sunFlowerLen[sun],[i,j])
				for k in range(sun,9):
					sunFlowerLen[k] = sunFlowerLen[k]+1
	
		sunLens = len(sunFlower)
		for i in range(10):
			if flag:
				break
			if sunLens > 10 and i < 9:
				min = sunFlowerLen[8-i]
			else:
				min = 9
			for j in range(min,sunLens):
				f0.move_abs(sunFlower[j][0],sunFlower[j][1])
				if get_water() < 0.75 :
					use_item(Items.Water)
				if can_harvest():
					harvest()
					# if num_items(Items.Power) >= 10000:
					# 	flag = True
					# 	break
						
				sunLens = min

set_world_size(8)

plantSunflower(0,0,7,7)